package com.aplink.generic.xmlparser;

import org.w3c.dom.Node;

import android.text.TextUtils;

import com.aplink.generic.pojo.controlspec.CheckBoxSpec;

public class CheckBoxParser {
	public static final String DISABLE_GROUP = "disableGroup";
	public static final String HIDE_GROUP = "hideGroup";
	public static final String INVISIBILITY_GROUP = "invisibilityGroup";
	public static final String TEXT_OFF = "textOff";
	public static final String TEXT_ON = "textOn";
	public static final String VALUE_OFF = "valueOff";
	public static final String VALUE_ON = "valueOn";

	public static CheckBoxSpec parse(final Node node) {
		final CheckBoxSpec switchSpec = new CheckBoxSpec();
		if (node.hasAttributes()) {
			String value = XmlPaserUtil.getAttrValue(node,
					CheckBoxParser.VALUE_ON);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setValueOn(value);
			}

			value = XmlPaserUtil.getAttrValue(node, CheckBoxParser.VALUE_OFF);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setValueOff(value);
			}
			value = XmlPaserUtil.getAttrValue(node, CheckBoxParser.TEXT_ON);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setTextOn(value);
			}

			value = XmlPaserUtil.getAttrValue(node, CheckBoxParser.TEXT_OFF);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setTextOff(value);
			}
			value = XmlPaserUtil.getAttrValue(node,
					CheckBoxParser.DISABLE_GROUP);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setDisableGroupID(value);
			}
			value = XmlPaserUtil.getAttrValue(node, CheckBoxParser.HIDE_GROUP);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setHideGroupID(value);
			}
			value = XmlPaserUtil.getAttrValue(node,
					CheckBoxParser.INVISIBILITY_GROUP);
			if (!TextUtils.isEmpty(value)) {
				switchSpec.setVisibilityGroupID(value);
			}
		}
		return switchSpec;
	}

}
